package com.qk.management.mapper;

import com.qk.entity.Activity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
@SuppressWarnings("all")
public interface ActivityMapper {
    @Delete("delete from activity where id = #{id}")
    void deleteById(Integer id);

    void update(Activity activity);

    @Select("select * from activity where id = #{id}")
    Activity selectById(Integer id);

    @Insert("insert into activity(channel, name, start_time, end_time, description, type, discount, voucher, create_time, update_time) values(#{channel}, #{name}, #{startTime}, #{endTime}, #{description}, #{type}, #{discount}, #{voucher}, #{createTime}, #{updateTime})")
    void insert(Activity activity);

    List<Activity> list(
            @Param("channel") Integer channel,
            @Param("type") Integer type,
            @Param("status") Integer status);

    Integer count(Integer channel, Integer type, Integer status);

    List<Activity> selectByPage(Integer channel, Integer type, Integer status, Integer offset, Integer pageSize);

    @Select("select * from activity where type = #{type}")
    List<Activity> listByType(Integer type);
}